package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.ImmPurchaseDeatis;
import com.drug.mingkang.Mapper.ImmPurchaseDeatisMapper;
import com.drug.mingkang.service.ImmPurchaseDeatisService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ImmPurchaseDeatis)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("immPurchaseDeatisService")
public class ImmPurchaseDeatisServiceImpl implements ImmPurchaseDeatisService {
    @Resource
    private ImmPurchaseDeatisMapper immPurchaseDeatisMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param deatisId 主键
     * @return 实例对象
     */
    @Override
    public ImmPurchaseDeatis queryById(String deatisId) {
        return this.immPurchaseDeatisMapper.queryById(deatisId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ImmPurchaseDeatis> queryAllByLimit(int offset, int limit) {
        return this.immPurchaseDeatisMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param immPurchaseDeatis 实例对象
     * @return 实例对象
     */
    @Override
    public ImmPurchaseDeatis insert(ImmPurchaseDeatis immPurchaseDeatis) {
        this.immPurchaseDeatisMapper.insert(immPurchaseDeatis);
        return immPurchaseDeatis;
    }

    /**
     * 修改数据
     *
     * @param immPurchaseDeatis 实例对象
     * @return 实例对象
     */
    @Override
    public ImmPurchaseDeatis update(ImmPurchaseDeatis immPurchaseDeatis) {
        this.immPurchaseDeatisMapper.update(immPurchaseDeatis);
        return this.queryById(immPurchaseDeatis.getDeatisId());
    }

    /**
     * 通过主键删除数据
     *
     * @param deatisId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String deatisId) {
        return this.immPurchaseDeatisMapper.deleteById(deatisId) > 0;
    }
}